package chapter1.No1_2_使用多线程.a继承Thread类;

/**
 * *：线程执行的随机性
 *
 * @author liujian
 * @version 2016/11/8 0008
 */
public class T3_RandomThread extends Thread {
    @Override
    public void run() {
        try {
            for (int i = 0; i < 10; i++) {
                Thread.sleep((int) Math.random() * 100);
                System.out.println("run=" + Thread.currentThread().getName());
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        T3_RandomThread randomThread = new T3_RandomThread();
        randomThread.setName("RandomThread");
        randomThread.start();

        T3_RandomThread randomThread2 = new T3_RandomThread();
        randomThread2.setName("R2");
        randomThread2.start();

    }
}
